import http from '@/utils/request'

// API基础路径
const API_BASE = '/menu'

/**
 * 获取菜单列表
 */
export const getMenuListApi = (params) => {
  return http.get(`${API_BASE}/list`, params)
}

/**
 * 获取菜单树形结构
 */
export const getMenuTreeApi = () => {
  return http.get(`${API_BASE}/tree`)
}

/**
 * 创建菜单
 */
export const createMenuApi = (data) => {
  return http.post(`${API_BASE}/create`, data)
}

/**
 * 更新菜单
 */
export const updateMenuApi = (data) => {
  return http.put(`${API_BASE}/update`, data)
}

/**
 * 删除菜单
 */
export const deleteMenuApi = (id) => {
  return http.delete(`${API_BASE}/delete`, { id })
}

/**
 * 获取菜单详情
 */
export const getMenuDetailApi = (id) => {
  return http.get(`${API_BASE}/detail`, { id })
}

/**
 * 获取用户路由
 */
export const getUserRoutesApi = () => {
  return http.get(`${API_BASE}/routes`)
}

/**
 * 获取角色菜单权限
 */
export const getRoleMenusApi = (roleId) => {
  return http.get(`${API_BASE}/role-menus`, { roleId })
}

/**
 * 获取菜单按钮权限
 */
export const getMenuButtonsApi = (menuId) => {
  return http.get(`${API_BASE}/buttons`, { menuId })
}

/**
 * 导出菜单数据
 */
export const exportMenuDataApi = () => {
  return http.get(`${API_BASE}/export`, {}, { responseType: 'blob' })
}

/**
 * 导入菜单数据
 */
export const importMenuDataApi = (file) => {
  return http.upload(`${API_BASE}/import`, file)
} 